//后台中间路由
'use strict';
//定义产量，是唯一的，不能重复定义，跟VAR不一样
const path = require('path');

const classRouter = require('./classRouter.js');
const studentRouter = require('./studentRouter.js');
const subjectRouter = require('./subjectRouter.js');
const mainRouter = require('./mainRouter.js');
//用函数定义对象
const Router = function (app) {
    // app.get('*',function(req,res,next){
    //      if(req.url!='/admin/main/register'&& req.url!='/admin/main/login'&&req.url.search(/\/admin\/main/) === -1){
    //      }
    // });
    //写后台权限
    app.use('/admin/class', classRouter);
    app.use('/admin/student', studentRouter);
    app.use('/admin/subject', subjectRouter);
    app.use('/admin/main', mainRouter);
    app.use('/', function (req, res) {
        // 跳转
        res.redirect('/admin/main/login')		// 写域名，直接访问登录页
    });
}

module.exports = Router;